﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using MinhTam.DataAccess.Web;

public partial class ketquadg : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            hienthi_danhgia();

        }
    }
    public void hienthi_danhgia()
    {
        try
        {
            
            String sql = @"select * from danh_gia";
            DataTable table = SQLConnectWeb.GetData(sql);

            //Sum danh gia
            String sql_sum = @"select sum(diem) as tongdiem from danh_gia";
            DataTable table_sum = SQLConnectWeb.GetData(sql_sum);

            double tongdiem = double.Parse(table_sum.Rows[0]["tongdiem"].ToString());

            DataColumn col;
            col = new DataColumn("tile", System.Type.GetType("System.String"));
            table.Columns.Add(col);

            int i=0;
            foreach (DataRow dr in table.Rows)
            {
                double diem = double.Parse(dr[2].ToString());

                double tile = (diem / tongdiem)*100;

                table.Rows[i]["tile"] = string.Format("{0:0.00}%", tile);

                i += 1;
            }

            kqdg.DataSource = table;
            kqdg.DataBind();

            tongdanhgia.Text = tongdiem.ToString();
        }
        catch
        {
        }
    }
}